﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//数据接收和发送模块
namespace MsgSendAndReceive
{
   
    public class MsgSendAndDisp
    {
        public event Action<object, MsgEventArgs> ReceivedMsg;//定义事件
        private TransData transD = new TransData(35000);
        public bool startServer()
        {
            MsgEventArgs e = new MsgEventArgs();
            e.msg = "Hello";
            e.ID = 100;
            transD.newMessage += DoDispMsg;
            return true;
        }
        public bool SengMsg(MsgEventArgs e)
        {
            return true;
        }
        internal void DoDispMsg(object senger,MsgEventArgs e)
        {
            string str = "发自MSGReceiveAndSend模块";
            //mylog.AppendStr(e.ID.ToString()+e.msg);
            if (ReceivedMsg != null)
            {
                mylog.AppendStr("发送消息,发送者消息ID："+e.ID+"，消息内容:"+e.msg);
                ReceivedMsg((object)str, e);
            }
            else
            {
                mylog.AppendStr("没有注册事件");
            }

        }

    }
}